package com.example.homework2;

import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class View_Page_Adapter extends RecyclerView.Adapter<View_Page_Adapter.View_Holder> {

    int[] num = {
            Color.BLACK,
            Color.BLUE,
            Color.GREEN,
            Color.GRAY
    };

    @NonNull
    @Override
    public View_Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new View_Holder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_page_item, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull View_Holder holder, int position) {
        holder.show_color_view.setBackgroundColor(num[position]);
    }

    @Override
    public int getItemCount() {
        return num.length;
    }

    public class View_Holder extends RecyclerView.ViewHolder {
        public LinearLayout show_color_view;

        public View_Holder(View itemView) {
            super(itemView);
            show_color_view = itemView.findViewById(R.id.show_color_view);
        }
    }

}
